<%--
  Created by IntelliJ IDEA.
  User: wk
  Date: 2020/5/14
  Time: 23:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>日志管理</title>
</head>
<script src="${pageContext.request.contextPath}/js/jquery-1.12.4.js"></script>
<script src="${pageContext.request.contextPath}/layui/layui.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css" type="text/css">
<script>
    function myTable(){
        layui.table.render({
            elem: '#logTable' //指定原始表格元素选择器（推荐id选择器）
            ,page:true
            ,url:'${pageContext.request.contextPath}/log/findAll'
            ,toolbar:"#myToolBar"
            ,cols: [[
                {field:'logId',title:'ID'},
                {field:'adminName',title:'管理员名字'},
                {field:'logDate',title:'操作日期'},
                {field:'logIp',title:'IP地址'},
                {field:'logType',title:'操作类型'},
                {field:'logContent',title:'操作内容'},
                {title:'操作',templet:"#caozuoTpl",align:"center"}
            ]] //设置表头
            //,…… //更多参数参考右侧目录：基本参数选项
        });
    }

    var table;
    var upload ;
    var form;
    var layer;
    layui.use(['element','layer','table','upload','form'], function() {
        element = layui.element;
        table = layui.table;
        upload = layui.upload;
        form = layui.form;
        layer=layui.layer;
        myTable();
    })
    function remove(id){
        layer.confirm("确认删除吗", {icon: 3, title:'确认框'}, function(index){
            $.ajax({
                url:"${pageContext.request.contextPath}/log/delete",
                data:{id:id},
                type:"POST",
                success:function (data) {
                    layer.msg(data.data, {
                        icon: 1,
                        time: 1000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        //do something
                        // 关闭弹出层
                        layer.closeAll();
                        //刷新表格
                        table.reload("logTable")
                        table.render();
                    });
                }
            })
        })
    }

</script>
<script type="text/html" id="caozuoTpl">
    <button type="button" class="layui-btn layui-btn-danger" onclick="remove({{d.logId}})">删除</button>
</script>
<body>
<table id="logTable"></table>
</body>
</html>
